(function($){
    $(document).ready(function () {
        /*模板引擎设置*/
        _.templateSettings = {
            interpolate: /\{\{(.+?)\}\}/g
        };

        var UserModel=Backbone.RelationalModel.extend({});

        var BuyerModel=Backbone.RelationalModel.extend({
            relations:[{
                type:Backbone.HasOne,
                key:"user",
                relatedModel:UserModel,
                reverseRelation:{
                    type:Backbone.HasOne,
                    key:"buyer"
                }
            }]
        });

        var userModel1=new UserModel({
            login:"jsmith",
            email:"497761497@qq.com",
            buyer:{
                firstName:"Wong",
                lastName:"Jian"
            }
        });

        var buyerModel1=new BuyerModel({
            firstName:"John",
            lastName:"Smith",
            //user:userModel1
            user:{
                login:"jsmith",
                email:"497761497@qq.com"
            }
        });

        console.log(buyerModel1.get("user").get("login"));
        console.log(userModel1.get("buyer").get("lastName"));
    });
})(jQuery);